package Sort;

public class BubbleSort {
    //冒泡排序
    public static void main(String[] args) {
        int[] arr={1,9,5,7,6,8,2,3,4,2,0,6};
        bubbleSort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }

    private static void bubbleSort(int[] arr) {
        //外循环：控制进行多少轮的循环
        for (int i = 0; i < arr.length-1; i++) {
            //内循环：一轮的循环
            for (int j = 0; j < arr.length-1; j++) {
                if(arr[j]>arr[j+1]){
                    int temp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }
            }
        }

    }

}
